class SessionsController < ApplicationController

	layout "posts"
	
  def new
  end

  def create
		@current_user = User.find_by_name_and_password(params[:login], params[:password])

		if @current_user
			session[:user_id] = @current_user.id
			if !(session[:return_to] == nil)
			redirect_to session[:return_to]
			session[:return_to] = nil
			else
				redirect_to home_path
			end
		else
			render :action=>'new'
		end
  end

  def destroy
		session[:user_id] = @current_user = nil
		redirect_to home_path
  end

end